﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Pampa.CRUD.Configuration;
using Pampa.MVC.Fluent.Crud.Groups;

namespace Pampa.MVC.Fluent.Crud.Items
{
    public class EntitySelectorItemBuilder<TGroup, TEditor, TEntity> : EntityAbstractItemBuilder<TGroup, TEditor, TEntity, EntitySelectorItemBuilder<TGroup, TEditor, TEntity>>
    {
        private readonly EntitySelectorItem _item;

        public EntitySelectorItemBuilder(EntitySelectorItem item, string parentGroupId) : base(item, parentGroupId)
        {
            _item = item;
        }

        public EntitySelectorItemBuilder(GroupBuilder<TGroup, TEditor> group, EntitySelectorItem item) : base(group, item)
        {
            _item = item;
        }

        public virtual EntitySelectorItemBuilder<TGroup, TEditor, TEntity> Description(Expression<Func<TEntity, object>> action)
        {
            _item.PropertyDescription = GetId(action);
            return this;
        }

        public EntitySelectorItemBuilder<TGroup, TEditor, TEntity> Size(int size)
        {
            _item.Size = size;
            return this;
        }

        public EntitySelectorItemBuilder<TGroup, TEditor, TEntity> EmptyText(string emptyText)
        {
            _item.EmptyText = emptyText;
            return this;
        }

        public EntitySelectorItemBuilder<TGroup, TEditor, TEntity> MinimunInputLength(int minimunInputLength)
        {
            _item.MinimumInputLength = minimunInputLength;
            return this;
        }

        public EntitySelectorItemBuilder<TGroup, TEditor, TEntity> Multiple()
        {
            _item.Multiple = true;
            return this;
        }
    }
}
